<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2019/1/25
 * Time: 18:27
 */
include_once '../model/adminDb.php';
include_once '../config/config.php';
$AdminDb = new adminDb();
$project = $_POST['project'];
$addtime = time();
$name = $_SESSION['name'];
$userData = $AdminDb->query_userName($name);
$idCard = $userData[0]['card'];
$projectName=$AdminDb->query_project_name($project);


if ($idCard == "1") {
    if (!$projectName) {
        $data = $AdminDb->add_project($project,$addtime);

        try {
            if ($data) {
                $dat = array(
                    "code" => 200,
                    "msg" => "添加成功",
                );
                echo json_encode($dat);

            } else {
                $dat = array(
                    "code" => 404,
                    "msg" => "添加失败",
                );
                echo json_encode($dat);
            }


        } catch (Exception $e) {
            echo $e->getMessage();
        }



    }
    else{

        $dat = array(
            'msg' => "操作失败，项目已存在",
            "code" => 102,

        );
        echo json_encode($dat);
    }


} else {
    $dat = array(
        'msg' => "操作失败，需管理员的权限",
        "code" => 102,

    );
    echo json_encode($dat);


}



